#include "Color.h"

Color::Color(std::ifstream &inputFile){
	inputFile >> r >> g >> b;
}

Color Color::operator +(const Color& c2){
	return Color(this->r + c2.r, this->g + c2.g, this->b + c2.b);
}

Color Color::operator*(double k){
	return Color(this->r * k, this->g * k, this->b * k);
}

Color Color::operator*(const Color& c2){ 
	return Color(this->r * c2.r, this->g * c2.g, this->b * c2.b);
}

Color& Color::operator +=(const Color &c2){
	r += c2.r;
	g += c2.g;
	b += c2.b;
	return *this;
}

unsigned char Color::getR(){
	return r > 1.0 ? 255 : (unsigned char)(255 * r);
}

unsigned char Color::getG(){
	return g > 1.0 ? 255 : (unsigned char)(255 * g);
}

unsigned char Color::getB(){
	return b > 1.0 ? 255 : (unsigned char)(255 * b);
}

